﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.Charting;

namespace FIFP.DashBoard.Views
{
    public partial class Scanario : UserControl
    {
        public Scanario()
        {
            InitializeComponent();

            InitDummyData();
            
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;
            if (cb.Name == "ScenarioA")
            {
                testChart.DefaultView.ChartArea.DataSeries.Add(dataList[0]);
            }
            else if (cb.Name == "ScenarioB")
            {
                testChart.DefaultView.ChartArea.DataSeries.Add(dataList[1]);
            }
            else if (cb.Name == "ScenarioC")
            {
                testChart.DefaultView.ChartArea.DataSeries.Add(dataList[2]);
            }
            else
            {
                testChart.DefaultView.ChartArea.DataSeries.Add(dataList[3]);
            }
        }

        private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;
            if (cb.Name == "ScenarioA")
            {
                testChart.DefaultView.ChartArea.DataSeries.Remove(dataList[0]);
            }
            else if (cb.Name == "ScenarioB")
            {
                testChart.DefaultView.ChartArea.DataSeries.Remove(dataList[1]);
            }
            else if (cb.Name == "ScenarioC")
            {
                testChart.DefaultView.ChartArea.DataSeries.Remove(dataList[2]);
            }
            else
            {
                testChart.DefaultView.ChartArea.DataSeries.Remove(dataList[3]);
            }
        }

        private List<DataSeries> dataList = new List<DataSeries>();

        private void InitDummyData()
        {
            DataSeries lineSeriesA = new DataSeries();
            lineSeriesA.LegendLabel = "Scenario A";
            lineSeriesA.Definition = new LineSeriesDefinition();
            lineSeriesA.Add(new DataPoint() { YValue = 352, XCategory = "2013/1" });
            lineSeriesA.Add(new DataPoint() { YValue = 320, XCategory = "2013/2" });
            lineSeriesA.Add(new DataPoint() { YValue = 290, XCategory = "2013/3" });
            lineSeriesA.Add(new DataPoint() { YValue = 300, XCategory = "2013/4" });
            lineSeriesA.Add(new DataPoint() { YValue = 260, XCategory = "2013/5" });
            lineSeriesA.Add(new DataPoint() { YValue = 280, XCategory = "2013/6" });
            lineSeriesA.Add(new DataPoint() { YValue = 370, XCategory = "2013/7" });
            lineSeriesA.Add(new DataPoint() { YValue = 310, XCategory = "2013/8" });
            lineSeriesA.Add(new DataPoint() { YValue = 340, XCategory = "2013/9" });
            lineSeriesA.Add(new DataPoint() { YValue = 289, XCategory = "2013/10" });
            lineSeriesA.Add(new DataPoint() { YValue = 311, XCategory = "2013/11" });
            lineSeriesA.Add(new DataPoint() { YValue = 301, XCategory = "2013/12" });

            DataSeries lineSeriesB = new DataSeries();
            lineSeriesB.LegendLabel = "Scenario B";
            lineSeriesB.Definition = new LineSeriesDefinition();
            lineSeriesB.Add(new DataPoint() { YValue = 340, XCategory = "2013/1" });
            lineSeriesB.Add(new DataPoint() { YValue = 322, XCategory = "2013/2" });
            lineSeriesB.Add(new DataPoint() { YValue = 300, XCategory = "2013/3" });
            lineSeriesB.Add(new DataPoint() { YValue = 280, XCategory = "2013/4" });
            lineSeriesB.Add(new DataPoint() { YValue = 280, XCategory = "2013/5" });
            lineSeriesB.Add(new DataPoint() { YValue = 350, XCategory = "2013/6" });
            lineSeriesB.Add(new DataPoint() { YValue = 320, XCategory = "2013/7" });
            lineSeriesB.Add(new DataPoint() { YValue = 325, XCategory = "2013/8" });
            lineSeriesB.Add(new DataPoint() { YValue = 300, XCategory = "2013/9" });
            lineSeriesB.Add(new DataPoint() { YValue = 280, XCategory = "2013/10" });
            lineSeriesB.Add(new DataPoint() { YValue = 305, XCategory = "2013/11" });
            lineSeriesB.Add(new DataPoint() { YValue = 309, XCategory = "2013/12" });


            DataSeries lineSeriesC = new DataSeries();
            lineSeriesC.LegendLabel = "Scenario C";
            lineSeriesC.Definition = new LineSeriesDefinition();
            lineSeriesC.Add(new DataPoint() { YValue = 330, XCategory = "2013/1" });
            lineSeriesC.Add(new DataPoint() { YValue = 315, XCategory = "2013/2" });
            lineSeriesC.Add(new DataPoint() { YValue = 340, XCategory = "2013/3" });
            lineSeriesC.Add(new DataPoint() { YValue = 296, XCategory = "2013/4" });
            lineSeriesC.Add(new DataPoint() { YValue = 285, XCategory = "2013/5" });
            lineSeriesC.Add(new DataPoint() { YValue = 330, XCategory = "2013/6" });
            lineSeriesC.Add(new DataPoint() { YValue = 350, XCategory = "2013/7" });
            lineSeriesC.Add(new DataPoint() { YValue = 335, XCategory = "2013/8" });
            lineSeriesC.Add(new DataPoint() { YValue = 300, XCategory = "2013/9" });
            lineSeriesC.Add(new DataPoint() { YValue = 290, XCategory = "2013/10" });
            lineSeriesC.Add(new DataPoint() { YValue = 300, XCategory = "2013/11" });
            lineSeriesC.Add(new DataPoint() { YValue = 310, XCategory = "2013/12" });


            DataSeries lineSeriesD = new DataSeries();
            lineSeriesD.LegendLabel = "Scenario D";
            lineSeriesD.Definition = new LineSeriesDefinition();
            lineSeriesD.Add(new DataPoint() { YValue = 300, XCategory = "2013/1" });
            lineSeriesD.Add(new DataPoint() { YValue = 298, XCategory = "2013/2" });
            lineSeriesD.Add(new DataPoint() { YValue = 310, XCategory = "2013/3" });
            lineSeriesD.Add(new DataPoint() { YValue = 285, XCategory = "2013/4" });
            lineSeriesD.Add(new DataPoint() { YValue = 340, XCategory = "2013/5" });
            lineSeriesD.Add(new DataPoint() { YValue = 315, XCategory = "2013/6" });
            lineSeriesD.Add(new DataPoint() { YValue = 330, XCategory = "2013/7" });
            lineSeriesD.Add(new DataPoint() { YValue = 310, XCategory = "2013/8" });
            lineSeriesD.Add(new DataPoint() { YValue = 295, XCategory = "2013/9" });
            lineSeriesD.Add(new DataPoint() { YValue = 305, XCategory = "2013/10" });
            lineSeriesD.Add(new DataPoint() { YValue = 300, XCategory = "2013/11" });
            lineSeriesD.Add(new DataPoint() { YValue = 320, XCategory = "2013/12" });




            dataList.Add(lineSeriesA);
            dataList.Add(lineSeriesB);
            dataList.Add(lineSeriesC);
            dataList.Add(lineSeriesD);

            //testChart.DefaultView.ChartArea.DataSeries.Add(lineSeriesA);
            //testChart.DefaultView.ChartArea.DataSeries.Add(lineSeriesB);
            //testChart.DefaultView.ChartArea.DataSeries.Add(lineSeriesC);
            //testChart.DefaultView.ChartArea.DataSeries.Add(lineSeriesD);
        }

    }
}
